package com.kaibes.platform.currency.api;

import java.util.List;

import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.kaibes.platform.currency.db.Currency;
import com.kaibes.platform.currency.db.CurrencyService;
import com.kaibes.platform.currency.pojo.CurrencyUpdate;
import com.kaibes.web.api.ApiLink;
import com.kaibes.web.api.ResponseApi;

@RestController
@RequestMapping("/currencys/infos")
public class CurrencyApi extends ResponseApi<Currency, CurrencyService> {

    @PostMapping
    @ApiLink("创建货币")
    public ResponseEntity<List<Number>> post(@RequestBody Currency data) {
        return super.post(data, "创建货币成功", "创建货币失败");
    }
    
    @DeleteMapping
    @ApiLink("删除货币，根据id")
    public ResponseEntity<Object> deleteByIds(@RequestBody List<Integer> ids) {
        return super.deleteById(ids, "删除货币成功", "删除货币失败");
    }
    
    @DeleteMapping("/{id:\\d+}")
    @ApiLink("删除货币，根据id")
    public ResponseEntity<Object> deleteById(@PathVariable Integer id) {
        return super.deleteById(id, "删除货币成功", "删除货币失败");
    }
    
    @PutMapping("/{id:\\d+}")
    @ApiLink("修改货币，根据id")
    public ResponseEntity<Object> putById(@PathVariable Integer id, @RequestBody CurrencyUpdate data) {
        return super.putById(data, id, "修改货币成功", "修改货币失败");
    }
    
}
